import config from './config'
import request from './request'

// import { useAppStoreWithOut } from '@/store/modules/app'
// const appStore = useAppStoreWithOut()
// import {AxiosPromise} from 'axios'

/**
 * 通用请求方法
 */
function fetch ({
  url,
  method,
  params,
  data,
  headers,
  contentType,
  responseType
}) {
  return request({
    url: url,
    method,
    // params: appStore.getRequestTime ? { time: new Date().getTime(), ...(params || {}) } : params,
    params,
    data,
    responseType: responseType,
    headers: Object.assign({
      'Content-Type': contentType || config.defaultHeaders
    }, headers)
  })
}

export default fetch
